import { getMaintenanceRequest } from "@/apis/mainTenance"
import { makeAutoObservable } from "mobx"
import { makePersistable } from "mobx-persist-store"
interface mainType {
	username: string,
	phone: string,
	number: string,
	position: string,
	notes: string,
	picture: string,
	createAt: any,
	id: number,
	parkingType: string
	cost: number
}

export class mainTenanceStore {
	maintenances: mainType[] = []
	constructor() {
		makeAutoObservable(this, {}, { autoBind: true })
		makePersistable(this, {
			name: 'mainTenanceStore',
			properties: ['maintenances'],
			storage: window.localStorage,
		})
	}

	setMaintenances(m: mainType[]) {
		this.maintenances = m
	}

	getMaintenances() {
		getMaintenanceRequest().then((res: any) => {
			this.setMaintenances(res.result)
		})
	}
}